package gob

import (
	"bytes"
	stdgob "encoding/gob"
)

func Marshal(v any) ([]byte, error) {
	buf := bytes.NewBuffer(nil)
	err := stdgob.NewEncoder(buf).Encode(v)
	if err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}

func Unmarshal(data []byte, v any) error {
	buf := bytes.NewBuffer(data)
	return stdgob.NewDecoder(buf).Decode(v)
}
